package com.daiqiu.manager.util;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import org.springframework.stereotype.Component;

import java.sql.SQLException;

public class GetSource {
    String url = "jdbc:mysql://121.36.35.202:3306/bankdb";
    String username = "root";
    String passwd = "Hhu_19_307";
    String driverClassName = "com.mysql.cj.jdbc.Driver";

    public DruidDataSource Source() {
        DruidDataSource source = new DruidDataSource();
        source.setUrl(url);
        source.setUsername(username);
        source.setPassword(passwd);
        source.setDriverClassName(driverClassName);
        source.setMaxActive(20);
        source.setMaxWait(60000);
        source.setMinIdle(5);
        source.setInitialSize(5);
        return source;
    }

    public DruidPooledConnection getConnection()  {
        DruidDataSource dataSource = Source();
        DruidPooledConnection con = null;
        try {
            con = dataSource.getConnection();
        }catch (Exception ignored) {
            System.out.println(111111111);
        }
        return con;
    }
}
